package net.zisen.cloud.order.fallback;

import feign.hystrix.FallbackFactory;
import lombok.extern.log4j.Log4j2;
import net.zisen.cloud.base.msg.ResultMsg;
import net.zisen.cloud.order.client.OrderServiceClient;
import net.zisen.cloud.order.model.Order;
import org.springframework.stereotype.Component;

/**
 * @author tim/278002989@qq.com
 * @Classname OrderClientFallbackFactory
 * @Description TODO
 * @Date 2019-05-17 15:59
 */
@Component
@Log4j2
public class OrderClientFallbackFactory implements FallbackFactory<OrderServiceClient> {


    @Override
    public OrderServiceClient create(Throwable throwable) {

        log.error("订单错误：{}", throwable.getMessage());
        return new OrderServiceClient() {
            @Override
            public ResultMsg<Order> addOrder(Long uid, Long goodsId, Integer quality) {
                return ResultMsg.fail("创建订单失败");
            }

            @Override
            public ResultMsg payOrder(String orderNum) {
                return ResultMsg.fail("生成订单签名失败");
            }
        };

    }
}
